import server from '@/utils/fetch'
const api = {
  user: {
    info: () => server.get('/api/user/info'),
    messageCode: params => server.get('api/message_code', params),
    login: params => server.post('/api/login', params)
  },
  home: {
    banner: () => server.get('/api/home/banner'),
    menu: () => server.get('/api/home/menu'),
    nav: () => server.get('/api/home/nav')
  },
  product: {
    list: (params = {}) => server.get('/api/product/list', params),
    classify: () => server.get('/api/classify/list'),
    serarchKey: (params) => server.get('/api/classify/serarchKey', params)
  },
  address: {
    create: (params = {}) => server.post('/api/address', params),
    select: () => server.get('/api/address'),
    get: (id) => server.get(`/api/address/${id}`),
    remove: (id) => server.delete(`/api/address/${id}`),
    update: (id, params) => server.put(`/api/address/${id}`, params)
  },

  car: {
    add: (id) => server.post('/api/car/add', {
      product_id: id
    }),
    list: () => server.get('/api/car'),
    update: params => server.put('/api/car', params),
  }
}

export default api
